from django.conf.urls import re_path
from rest_framework_jwt.views import obtain_jwt_token
from rest_framework.routers import DefaultRouter

from meiduo_admin.views import spu, permission, options, brands, group, admins
from .views import statistical,image,sku,orders

urlpatterns = [
    # Django REST framework JWT提供了登录签发JWT的视图，可以直接使用
    re_path(r'^authorizations/$', obtain_jwt_token),
    # 用户总量统计
    re_path(r'^statistical/total_count/$', statistical.UserTotalCountView.as_view()),
    # 日活跃用户统计
    re_path(r'^statistical/day_active/$', statistical.UserDailyActiveCountView.as_view()),
    # 日下单用户量统计
    re_path(r'^statistical/day_orders/$', statistical.UserDailyOrderCountView.as_view()),
    # 日增用户统计
    re_path(r'^statistical/day_increment/$', statistical.UserDailyAddCountView.as_view()),
    # 月增用户统计
    re_path(r'^statistical/month_increment/$', statistical.UserMonthCountView.as_view()),
    # 查询用户
    re_path(r'^users/$', statistical.UserListView.as_view()),
    # 获取sku表id
    re_path(r'^skus/simple/$', image.SKUView.as_view()),
    # 获取三级分类信息
    re_path(r'^skus/categories/$', sku.SKUCategoriesView.as_view()),
    # 获取SPU表名称数据
    re_path(r'^goods/simple/$', sku.GoodsSimpleView.as_view()),
    # 获取SPU商品规格信息
    re_path(r'^goods/(?P<pk>\d+)/specs/$', sku.GoodsSpecView.as_view()),

    # 实现日分类商品访问量
    re_path(r'^statistical/goods_day_views/$', statistical.GoodDayCountView.as_view()),

    re_path(r'^orders/(?P<pk>\d+)/$', orders.Order_pkView.as_view()),

    # # 获取订单表数据
    # re_path(r'^orders/$', orders.OrdersView.as_view()),

    # 获取品牌信息数据
    re_path(r'^goods/brands/simple/$', spu.SPUSimpleView.as_view()),
    # 获取一级分类信息
    re_path(r'^goods/channel/categories/$', spu.SPUCategoriesView.as_view()),
    # 获取二级和三级分类
    re_path(r'^goods/channel/categories/(?P<pk>\d+)/$', spu.SPUCategories2View.as_view()),
    # 获取权限类型列表数据
    re_path(r'^permission/content_types/$', permission.ContentTypeAPIView.as_view()),
    # 规格选项表数据-->获取品牌信息数据
    re_path(r'^goods/specs/simple/$', options.SpecsSimpleView.as_view()),
    # 获取权限表数据
    re_path(r'^permission/simple/$', group.PermissionSimple.as_view()),
    # 获取分组表数据
    re_path(r'^permission/groups/simple/$', admins.GroupsSimpleView.as_view()),
    #

]

#创建router实例
router = DefaultRouter()
#注册路由
router.register(r'skus/images',image.ImageView,basename='image')
#将router生成的路由追加到urlpatterns中
urlpatterns += router.urls

# 获取SKU表数据
router.register(r'skus',sku.SKUModelViewSet,basename='skus')
#将router生成的路由追加到urlpatterns中
urlpatterns += router.urls

# 获取订单表数据
router.register(r'orders',orders.OrdersView,basename='orders')
# 将router生成的路由追加到urlpatterns中
urlpatterns += router.urls

# 获取规格表数据
router.register(r'goods/specs',spu.GoodssSpecsView,basename='specs')
# 将router生成的路由追加到urlpatterns中
urlpatterns += router.urls

# 品牌管理
router.register(r'goods/brands',brands.GoodsBrandsView,basename='brands')
urlpatterns += router.urls

# 获取SPU表数据
router.register(r'goods',spu.SPUModelViewSet,basename='goods')
# 将router生成的路由追加到urlpatterns中
urlpatterns += router.urls

# 获取用户权限表列表数据
router.register(r'permission/perms',permission.PermissionView,basename='perms')
urlpatterns += router.urls

# 获取规格选项表管理
router.register(r'specs/options',options.SpecsOptionsView,basename='options')
urlpatterns += router.urls

# 分组表数据管理
router.register(r'permission/groups',group.GroupsView,basename='groups')
urlpatterns += router.urls

# 管理员信息管理
router.register(r'permission/admins',admins.AdminsView,basename='groups')
urlpatterns += router.urls